package com.zs.leymovie.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;

import com.loopj.android.image.SmartImageView;

import java.util.List;

/**
 * Created by Administrator on 2015/8/19.
 */
public class GalleryImgAdapter extends BaseAdapter {
    private List<String> lists;
    private Context context;
    private int selectItem;
    public GalleryImgAdapter (List<String> lists,Context context){
        this.lists = lists;
        this.context = context;
    }
    @Override
    public int getCount() {
        return lists.size();
    }

    @Override
    public Object getItem(int position) {
        return lists.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        SmartImageView imageView = new SmartImageView(context);

        imageView.setImageUrl(lists.get(position));
        imageView.setLayoutParams(new Gallery.LayoutParams(300,400));

        if(selectItem == position){
               imageView.setAlpha(1.0f);
        }else{
               imageView.setAlpha(0.4f);
        }
    return imageView;
    }

    public void setSelectItem(int selectItem) {

        if (this.selectItem != selectItem) {
            this.selectItem = selectItem;
            notifyDataSetChanged();
        }
    }
}
